//
//  GetHeightTools.m
//  UI12_自定义Cell的行高
//
//  Created by dllo on 16/6/22.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "GetHeightTools.h"

@implementation GetHeightTools

+(CGFloat)heightWith:(NSString *)text withWidth:(CGFloat)width withFontSize:(CGFloat)fontSize{
    
    NSDictionary *attributeDic = @{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]};
    
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake(width, 10000) options:NSStringDrawingUsesLineFragmentOrigin  attributes:attributeDic context:nil];
    
    return rect.size.height;
}

+(CGFloat)imageHeightWith:(NSString *)imageName{
    
    UIImage *image = [UIImage imageNamed:imageName];
    /** 根据图片的宽高比例算出自适应高度. */
    CGFloat height =  image.size.height * [UIScreen mainScreen].bounds.size.width / image.size.width;
    
    
    return height;
    
    
}



@end
